package com.xneure.code.exception;

import java.util.ArrayList;
import java.util.List;

public class ExceptionReport{
	List<Report> list = new ArrayList<Report>(10);

	public void addReport(Report erport){
		list.add(erport);
	}

	public String getReport(){
		StringBuilder sb = new StringBuilder();
		for(Report r:list){
			sb.append(r.getErrMsg());
		}
		return sb.toString();
	}

	public String getReport(ExceptionLevel level){
		StringBuilder sb = new StringBuilder();
		for(Report r:list){
			if(r.getErrLevel() == level){
				sb.append(r.getErrMsg());
				sb.append("\r\n");
			}
		}
		return sb.toString();
	}

	public boolean isError(){
		return list.size() > 0;
	}
	public int querReports(ExceptionLevel level){
		int count = 0;
		for(Report r:list){
			if(r.getErrLevel() == level){
				count++;
			}
		}
		return count;
	}
}
